"""
http请求和相应
"""
from socket import *

sock = socket()
sock.bind(('0.0.0.0', 8888))
sock.listen(5)

conn, addr = sock.accept()
print("Connect from ", addr)

data = conn.recv(1024)
print(data.decode())

# 组织http响应格式
response = """HTTP/1.1 200 OK
Content-Type:text/html

Hello World
"""

conn.send(response.encode())

conn.close()
sock.close()
